Skip to content

BUG: Rolling negative window issue fix #13383 #13441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

priyankjain
Copy link
Contributor

@priyankjain priyankjain commented Jun 14, 2016

Added functionality in validate function of Rolling to ensure that window size is non-negative.

@codecov-io
Copy link

codecov-io commented Jun 14, 2016

Current coverage is 84.32%

Merging #13441 into master will increase coverage by <.01%

@@             master     #13441   diff @@
==========================================
  Files           138        138          
  Lines         51068      51072     +4   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43065      43069     +4   
  Misses         8003       8003          
  Partials          0          0          

Powered by Codecov. Last updated by b06bc7a...26c9b2d

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jun 14, 2016
@@ -850,6 +850,8 @@ def validate(self):
super(Rolling, self).validate()
if not com.is_integer(self.window):
raise ValueError("window must be an integer")
elif self.window < 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a another place where this is checked. in _Window (so need a test for that as well)

@@ -320,7 +320,7 @@ def validate(self):
window = self.window
if isinstance(window, (list, tuple, np.ndarray)):
pass
elif com.is_integer(window):
elif com.is_integer(window) and window >= 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do this inside the elif

elif com.is_integer(window):
    if window < 0:
          raise ......
   ...

try:
import scipy.signal as sig
except ImportError:
raise ImportError('Please install scipy to generate window'
Copy link
Contributor Author

@priyankjain priyankjain Jun 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, the test case
series.rolling(0, win_type='boxcar') fails,
should we change travis configuration file (requirements-3.5_OSX.build) to have scipy installation as part of the build or change the test case to handle the import error? @jreback

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the test case to skip if scipy is not installed

@@ -1,2 +1,3 @@
numpy=1.10.4
cython
scipy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is left off on purpose

@priyankjain priyankjain force-pushed the novice-bug-fixes branch 3 times, most recently from 9da3800 to 967ffb8 Compare June 16, 2016 15:56
@@ -339,6 +344,13 @@ def test_constructor(self):
c(window=2, min_periods=w)
with self.assertRaises(ValueError):
c(window=2, min_periods=1, center=w)
# GH 13383
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this a separate test (as skipping will cause the entire rest of the test to be skipped)

@jreback jreback added this to the 0.18.2 milestone Jun 21, 2016
@jreback jreback closed this in 0f351dc Jun 21, 2016
@jreback
Copy link
Contributor

jreback commented Jun 21, 2016

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series.rolling/DataFrame.rolling don't fully check arguments, have odd behavior when used with invalid inputs
3 participants